package com.company.project.common.enums;

/**
 * 枚举类：定义支持的攻击类型
 */
public enum AttackEnum {
    /**
     * DDoS 攻击
     */
    DDOS(1, "ddos"),

    /**
     * DNS 投毒攻击
     */
    DNS_POISONING(2, "dns_poisoning"),

    /**
     * ARP 欺骗攻击
     */
    ARP_SPOOFING(3, "arp_spoofing"),

    /**
     * TCP SYN Flood 攻击
     */
    SYN_FLOOD(4, "syn_flood");

    private final int code;
    private final String msg;

    AttackEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 获取攻击类型的代码
     */
    public int getCode() {
        return code;
    }

    /**
     * 获取攻击类型的消息
     */
    public String getMsg() {
        return msg;
    }

    /**
     * 根据代码获取对应的消息
     */
    public static String getMsgByCode(int code) {
        for (AttackEnum attack : AttackEnum.values()) {
            if (attack.getCode() == code) {
                return attack.getMsg();
            }
        }
        throw new IllegalArgumentException("Unknown attack type code: " + code);
    }
}

